import org.junit.Before;
import org.junit.Test;
import cn.jolyoulu.common.core.cache.def.DefaultLocalCacheBootStrap;
import cn.jolyoulu.common.core.cache.def.DefaultLocalCacheEvictPolicy;
import cn.jolyoulu.common.core.cache.def.DefaultLocalCacheOperator;

/**
 * @Author: JolyouLu
 * @Date: 2023/4/15 20:23
 * @Description
 */
public class DefaultCacheTest {
    private DefaultLocalCacheOperator defaultCacheOperator;

    @Before
    public void before() {
        //缓存操作
        defaultCacheOperator = new DefaultLocalCacheOperator(2);
        //缓存启动用到
        new DefaultLocalCacheBootStrap(defaultCacheOperator, new DefaultLocalCacheEvictPolicy());
    }

    @Test
    public void test1() {
        for (int i = 0; i < 10; i++) {
            boolean set = defaultCacheOperator.set(String.valueOf(i), "测试测试" + i);
            System.out.println("设置缓存是否成功 " + set);
        }
        System.out.println("缓存容量 == " + defaultCacheOperator.keys().size());
        System.out.println(defaultCacheOperator.get("1"));
    }
}
